﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace E1_eMart.admin
{
    public partial class usermanagement : System.Web.UI.Page
    {
        public TaiKhoan gTaiKhoan = new TaiKhoan();
        protected int loaiTaiKhoan = -1;
        public List<TaiKhoan> listAccount = new List<TaiKhoan>();
        public int numberPage = 0;
        int numberSize = 50;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["username"] != null)
            {
                gTaiKhoan = (TaiKhoan)Session["username"];
                loaiTaiKhoan = (int)gTaiKhoan.MaLoaiTaiKhoan;
            }

            DataClasses1DataContext edata = new DataClasses1DataContext();
            if (Request.Params["p"] != null)
            {
                int pageCurent = int.Parse(Request.Params["p"].ToString());
                var listac = from ac in edata.TaiKhoans
                              select ac;
                numberPage = listac.Count() / numberSize + 1;
                //if (pageCurent == 0)
                //    listAccount = listac.Take(numberSize).ToList<TaiKhoan>();
                //else
                    listAccount = listac.Skip(pageCurent * numberSize).Take(numberSize).ToList<TaiKhoan>();

            }
            else
            {
                var listac = from ac in edata.TaiKhoans
                              select ac;
                numberPage = listac.Count() / numberSize + 1;
                listAccount = listac.Take(numberSize).ToList<TaiKhoan>();
            }
            
        }
    }
}